import {Component, OnInit, ViewChild} from '@angular/core';
import {Router} from '@angular/router';
import {PopupComponent} from 'ngx-weui';
import {TimeService} from '../service/timeservice/time.service';

@Component({
  selector: 'app-phomepage',
  templateUrl: './phomepage.component.html',
  styleUrls: ['./phomepage.component.css']
})
export class PhomepageComponent implements OnInit {
  type = 'loading';
  first = false;
  icon= true; // weui-icon-checked
  radio: any;
  num = 0; // tag是编辑还是确认
  res: any = {
    cho2: true,
    agree: true
  };
  @ViewChild('simple') simplePopup: PopupComponent; // 底部
  constructor(private router: Router, private service: TimeService) {
    this.radio = this.service.person; // 就诊人列表
    this.res.radio = this.radio[0]; // 默认选中第一个

  }

  check() {
    this.simplePopup.hide();
  }
  ngOnInit() {
    setTimeout(() => this.first = true , 300);
  }

  confirm() {
    this.icon = !this.icon;
    this.num++;
    if ( this.num % 2 !== 0) {
      this.simplePopup.config.confirm = '完成';
    }
    if ( this.num % 2 === 0) {
      this.simplePopup.config.confirm = '编辑';
    }
  }

  // 底部弹出框取消按钮事件
  cancel() {
    this.icon = true;
    this.simplePopup.config.confirm = '完成';
  }
  gopatientpayrecord() {
    this.router.navigate(['/outpatientpayrecord/outpatientpayrecord']);
  }
  editPatient() {
    this.router.navigate(['/patient/editpatient']);
  }
  goappoint() {
    this.router.navigate(['/appointrecord/appointrecord']);
}
  goappointinfo() {
    this.router.navigate(['/appointrecordinfo']);
  }
  gomedicalrecords() {
    this.router.navigate(['/medicalrecord/medicalrecords']);
  }
  goinspections() {
    this.router.navigate(['/inspectionrecord']);
  }
}
